﻿using HDS.Common.Helper;
using Serilog;
using Serilog.Context;
using System;
using System.Threading;

namespace TestConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            new AppSettings();

            Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(AppSettings.CustomConfig).CreateLogger();

            Console.WriteLine("panhonghao".CreatePassword());
            //Log.Logger = new LoggerConfiguration()
            //   .MinimumLevel.Debug()
            //   .Enrich.WithProperty("Application", "Demo")
            //   .WriteTo.Console()
            //   .WriteTo.File("log/log.log", rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true)
            //   .WriteTo.MongoDBCapped(AppSettings.GetAppSettingValue("MongoDB", "Log"), collectionName: "rollingapplog")
            //   .CreateLogger();

            LogContext.PushProperty("SC", "TestConsoleApp.Program");

            Log.Debug("test");
            Log.ForContext("Number", 1).Information("Hello, Serilog!");
            var position = new { Latitude = 25, Longitude = 134 };
            var elapsedMs = 34;

            Log.Information("Processed {@Position} in {Elapsed} ms.", position, elapsedMs);

            int a = 10, b = 0;
            try
            {
                Log.Debug("Dividing {A} by {B}", a, b);
                Console.WriteLine(a / b);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Something went wrong");
            }

            //Thread.Sleep(60000);

            //Log.CloseAndFlush();

            Console.ReadLine();
        }
    }
}
